﻿using System.Web;
using TwitterStatisticsModel;

namespace App_Code
{
    /// <summary>
    /// Summary description for Class1
    /// </summary>
    public static class TwitterEntitiesContext
    {
        public static TwitterEntities GetEntityContext(this HttpContext httpContext)
        {
            if (httpContext.Items["context"] == null)
            {
                httpContext.Items.Add("context", new TwitterEntities());
            }
            return (TwitterEntities) httpContext.Items["context"];
        }

        public static void DisposeContext(this HttpContext httpContext)
        {
            if (httpContext.Items["context"] != null)
            {
                ((TwitterEntities) httpContext.Items["context"]).Dispose();
            }
        }
    }
}